/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.util.bdfparser.enums.cardeums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 枚举所有支持的卡片类型
 */
@Getter
@AllArgsConstructor
public enum CardNameEnums {

    // nodes
    GRID("GRID"), GRDSET("GRDSET"), SPOINT("SPOINT"), EPOINT("EPOINT"), SEQGP("SEQGP"), GRIDB("GRIDB"),

    // points
    POINT("POINT"),

    // massses
    CONM1("CONM1"), CONM2("CONM2"),
    CMASS1("CMASS1"), CMASS2("CMASS2"), CMASS3("CMASS3"), CMASS4("CMASS4"),

    // nsms
    NSM("NSM"), NSM1("NSM1"), NSML("NSML"), NSML1("NSML1"),

    // nsmadds
    NSMADD("NSMADD"),

    // elements
    // springs
    CELAS1("CELAS1"), CELAS2("CELAS2"), CELAS3("CELAS3"), CELAS4("CELAS4"), CELAS5("CELAS5"),
    // bushings
    CBUSH("CBUSH"), CBUSH1D("CBUSH1D"), CBUSH2D("CBUSH2D"),
    // dampers
    CDAMP1("CDAMP1"), CDAMP2("CDAMP2"), CDAMP3("CDAMP3"), CDAMP4("CDAMP4"), CDAMP5("CDAMP5"), CFAST("CFAST"),

    // regular elements todo: 补充
    CBAR("CBAR"), CBARAO("CBARAO"), BAROR("BAROR"),
    CROD("CROD"), CTUBE("CTUBE"), CBEAM("CBEAM"), CBEAM3("CBEAM3"), CONROD("CONROD"), CBEND("CBEND"), BEAMOR("BEAMOR"),
    CTRIA3("CTRIA3"), CTRIA6("CTRIA6"), CTRIAR("CTRIAR"),
    CQUAD4("CQUAD4"), CQUAD8("CQUAD8"), CQUADR("CQUADR"), CQUAD("CQUAD"),
    CTRAX3("CTRAX3"), CTRAX6("CTRAX6"), CTRIAX("CTRIAX"), CTRIAX6("CTRIAX6"), CQUADX("CQUADX"), CQUADX4("CQUADX4"), CQUADX8("CQUADX8"),
    CTRSHL("CTRSHL"), CQUAD1("CQUAD1"),
    SNORM("SNORM"),
    CWELD("CWELD"),

    // plate strain
    CPLSTN3("CPLSTN3"), CPLSTN4("CPLSTN4"), CPLSTN6("CPLSTN6"), CPLSTN8("CPLSTN8"),
    // plate stress
    CPLSTS3("CPLSTS3"), CPLSTS4("CPLSTS4"), CPLSTS6("CPLSTS6"), CPLSTS8("CPLSTS8"),

    // acoustic
    CHACAB("CHACAB"), CAABSF("CAABSF"), CHACBR("CHACBR"),
    PACABS("PACABS"), PAABSF("PAABSF"), PACBAR("PACBAR"), ACMODL("ACMODL"),
    CTETRA("CTETRA"), CPYRAM("CPYRAM"), CPENTA("CPENTA"), CHEXA("CHEXA"),
    CIHEX1("CIHEX1"), CIHEX2("CIHEX2"), CHEXA1("CHEXA1"), CHEXA2("CHEXA2"),
    CSHEAR("CSHEAR"), CVISC("CVISC"), CRAC2D("CRAC2D"), CRAC3D("CRAC3D"),
    CGAP("CGAP"),
    GENEL("GENEL"),

    // rigid elements
    RBAR("RBAR"), RBAR1("RBAR1"), RBE1("RBE1"), RBE2("RBE2"), RBE3("RBE3"), RROD("RROD"), RSPLINE("RSPLINE"), RSSCON("RSSCON"),

    // plotels
    PLOTEL("PLOTEL"),

    // properties
    PMASS("PMASS"),
    PELAS("PELAS"), PGAP("PGAP"), PFAST("PFAST"), PLPLANE("PLPLANE"), PPLANE("PPLANE"),
    PBUSH("PBUSH"), PBUSH1D("PBUSH1D"),
    PDAMP("PDAMP"), PDAMP5("PDAMP5"),
    PROD("PROD"), PBAR("PBAR"), PBARL("PBARL"), PBEAM("PBEAM"), PTUBE("PTUBE"), PBCOMP("PBCOMP"), PBRSECT("PBRSECT"), PBEND("PBEND"),
    PBEAML("PBEAML"), PBMSECT("PBMSECT"),
    PBEAM3("PBEAM3"),

    PSHELL("PSHELL"), PCOMP("PCOMP"), PCOMPG("PCOMPG"), PSHEAR("PSHEAR"),
    PSOLID("PSOLID"), PLSOLID("PLSOLID"), PVISC("PVISC"), PRAC2D("PRAC2D"), PRAC3D("PRAC3D"),
    PCOMPS("PCOMPS"), PCOMPLS("PCOMPLS"),
    PMIC("PMIC"),
    PWELD("PWELD"),

    // nastran 95
    PTRSHL("PTRSHL"), PQUAD1("PQUAD1"),
    PIHEX("PIHEX"), // PQUAD4

    // axissymmetric
    CCONEAX("CCONEAX"),
    PCONEAX("PCONEAX"),
    AXIC("AXIC"),
    AXIF("AXIF"),
    FORCEAX("FORCEAX"),

    // pdampt
    PDAMPT("PDAMPT"),
    // pelast
    PELAST("PELAST"),
    // pbusht
    PBUSHT("PBUSHT"),
    // creep
    CREEP("CREEP"),

    // materials todo: 拓展支持的卡片类型
    MAT1("MAT1"), MAT2("MAT2"), MAT3("MAT3"), MAT8("MAT8"), MAT9("MAT9"), MAT10("MAT10"), MAT11("MAT11"),
    MAT3D("MAT3D"),
    MATG("MATG"), MATHE("MATHE"), MATHP("MATHP"), MATEV("MATEV"),
    // temperature dependent materials
    MATT1("MATT1"), MATT2("MATT2"), MATT3("MATT3"), MATT4("MATT4"), MATT5("MATT5"), MATT8("MATT8"), MATT9("MATT9"),
    // stress dependent materials
    MATS1("MATS1"), MATS3("MATS3"), MATS8("MATS8"),
    MATDMG("MATDMG"),
    // nxstrat
    NXSTRAT("NXSTRAT"),
    // thermal materials
    MAT4("MAT4"), MAT5("MAT5"),

    // single-point constraints
    SPC("SPC"), SPCADD("SPCADD"), SPC1("SPC1"), SPCAX("SPCAX"), SPCOFF("SPCOFF"), SPCOFF1("SPCOFF1"),

    // multi-point constraints
    MPC("MPC"), MPCADD("MPCADD"),

    // support
    SUPORT("SUPORT"), SUPORT1("SUPORT1"), SESUP("SESUP"),

    // dloads
    DLOAD("DLOAD"),

    // dload entries
    ACSRCE("ACSRCE"), TLOAD1("TLOAD1"), TLOAD2("TLOAD2"), RLOAD1("RLOAD1"), RLOAD2("RLOAD2"),
    QVECT("QVECT"),
    RANDPS("RANDPS"), RANDT1("RANDT1"),

    // loads
    LOAD("LOAD"), CLOAD("CLOAD"), LSEQ("LSEQ"), LOADCYN("LOADCYN"), LOADCYH("LOADCYH"),
    SLOAD("SLOAD"),
    FORCE("FORCE"), FORCE1("FORCE1"), FORCE2("FORCE2"),
    MOMENT("MOMENT"), MOMENT1("MOMENT1"), MOMENT2("MOMENT2"),
    GRAV("GRAV"), ACCEL("ACCEL"), ACCEL1("ACCEL1"),
    PLOAD("PLOAD"), PLOAD1("PLOAD1"), PLOAD2("PLOAD2"), PLOAD4("PLOAD4"),
    PLOADX1("PLOADX1"), RFORCE("RFORCE"), RFORCE1("RFORCE1"),
    SPCD("SPCD"), DEFORM("DEFORM"),

    // acoustic
    ACPLNW("ACPLNW"), AMLREG("AMLREG"), MATPOR("MATPOR"), MICPNT("MICPNT"),

    // axisymmetric
    PRESAX("PRESAX"),

    // thermal
    QVOL("QVOL"),

    // aero todo: 定义空力卡片

    // coords
    CORD1R("CORD1R"), CORD1C("CORD1C"), CORD1S("CORD1S"),
    CORD2R("CORD2R"), CORD2C("CORD2C"), CORD2S("CORD2S"),

    MATCID("MATCID"),

    // temperature
    TEMP("TEMP"), TEMPD("TEMPD"), TEMPB3("TEMPB3"), TEMPAX("TEMPAX"),
    QBDY1("QBDY1"), QBDY2("QBDY2"), QBDY3("QBDY3"), QHBDY("QHBDY"),
    CHBDYE("CHBDYE"), CHBDYG("CHBDYG"), CHBDYP("CHBDYP"),
    PCONV("PCONV"), PCONVM("PCONVM"), PHBDY("PHBDY"),
    RADBC("RADBC"), CONV("CONV"),
    RADM("RADM"), VIEW("VIEW"), VIEW3D("VIEW3D"), // todo: not validated
    RADCAV("RADCAV"),

    // dynamic cards
    DAREA("DAREA"),
    DPHASE("DPHASE"),
    DELAY("DELAY"),
    NLPARM("NLPARM"),
    ROTORG("ROTORG"),
    ROTORD("ROTORD"),
    NLPCI("NLPCI"),
    TSTEP("TSTEP"),
    TSTEPNL("TSTEPNL"),
    TSTEP1("TSTEP1"),
    TF("TF"),
    TIC("TIC"),

    // frequencies
    FREQ("FREQ"), FREQ1("FREQ1"), FREQ2("FREQ2"), FREQ3("FREQ3"), FREQ4("FREQ4"), FREQ5("FREQ5"),

    // direct matrix inputs
    DMIG("DMIG"), DMIJ("DMIJ"), DMIJI("DMIJI"), DMIK("DMIK"), DMI("DMI"), DTI("DTI"),
    DMIAX("DMIAX"),

    // optimization cards
    DEQATN("DEQATN"), DTABLE("DTABLE"),
    DCONSTR("DCONSTR"), DESVAR("DESVAR"), TOPVAR("TOPVAR"), DDVAL("DDVAL"), DRESP1("DRESP1"), DRESP2("DRESP2"), DRESP3("DRESP3"),
    DVCREL1("DVCREL1"), DVCREL2("DVCREL2"),
    DVPREL1("DVPREL1"), DVPREL2("DVPREL2"),
    DVMREL1("DVMREL1"), DVMREL2("DVMREL2"),
    DOPTPRM("DOPTPRM"), DLINK("DLINK"), DCONADD("DCONADD"), DVGRID("DVGRID"),
    DSCREEN("DSCREEN"),

    // nx optimization
    DVTREL1("DVTREL1"), GROUP("GROUP"), DMNCON("DMNCON"),

    // sets
    SET1("SET1"), SET2("SET2"), SET3("SET3"),
    ASET("ASET"), ASET1("ASET1"),
    OMIT("OMIT"), OMIT1("OMIT1"),
    BSET("BSET"), BSET1("BSET1"),
    CSET("CSET"), CSET1("CSET1"),
    QSET("QSET"), QSET1("QSET1"),
    USET("USET"), USET1("USET1"),
    RADSET("RADSET"),

    // superelements
    SETREE("SETREE"), SENQSET("SENQSET"), SEBULK("SEBULK"), SEBNDRY("SEBNDRY"), SEELT("SEELT"), SELOC("SELOC"), SEMPLN("SEMPLN"),
    SECONCT("SECONCT"), SELABEL("SELABEL"), SEEXCLD("SEEXCLD"), CSUPER("CSUPER"), CSUPEXT("CSUPEXT"),
    SELOAD("SELOAD"), RELEASE("RELEASE"),

    // superelement sets
    SESET("SESET"),
    SEBSET("SEBSET"), SEBSET1("SEBSET1"),
    SECSET("SECSET"), SECSET1("SECSET1"),
    SEQSET("SEQSET"), SEQSET1("SEQSET1"),
    SEQSEP("SEQSEP"),

    // parametric
    PSET("PSET"), PVAL("PVAL"), GMCURV("GMCURV"), GMSURF("GMSURF"), FEEDGE("FEEDGE"), FEFACE("FEFACE"),
    GMSPC("GMSPC"),

    // tables
    TABLED1("TABLED1"), TABLED2("TABLED2"), TABLED3("TABLED3"), TABLED4("TABLED4"),
    TABLEM1("TABLEM1"), TABLEM2("TABLEM2"), TABLEM3("TABLEM3"), TABLEM4("TABLEM4"),
    // material tables - nonlinear elastic temperature dependent materials
    TABLEST("TABLEST"),
    // material tables - stress (MATS1, CREEP, MATHP)
    TABLES1("TABLES1"),
    // modal damping table
    TABDMP1("TABDMP1"),
    // random_tables
    TABRND1("TABRND1"), TABRNDG("TABRNDG"), TABLEHT("TABLEHT"), TABLEH1("TABLEH1"),

    // methods
    EIGB("EIGB"), EIGR("EIGR"), EIGRL("EIGRL"),

    // cmethods
    EIGC("EIGC"), EIGP("EIGP"),

    // modtrak
    MODTRAK("MODTRAK"),

    // contacts
    BCBODY("BCBODY"), BCPARA("BCPARA"), BCTPARA("BCTPARA"), BCRPARA("BCRPARA"), BCTPARM("BCTPARM"),
    BGADD("BGADD"), BGSET("BGSET"), BCTADD("BCTADD"), BCTSET("BCTSET"), BSURF("BSURF"), BSURFS("BSURFS"),
    BCONP("BCONP"), BLSEG("BLSEG"), BFRIC("BFRIC"), TEMPBC("TEMPBC"),

    RADMT("RADMT"),
    RADLST("RADLST"),
    RADMTX("RADMTX"),
    TEMPRB("TEMPRB"),
    CONVM("CONVM"),

    // cyclic
    CYJOIN("CYJOIN"),
    CYAX("CYAX"),

    // bolt nx
    BOLT("BOLT"), BOLTSEQ("BOLTSEQ"), BOLTLD("BOLTLD"), BOLTFOR("BOLTFOR"),

    // hypermesh comment todo: 新增对 HyperMesh elements 的支持
    // reference site: https://2024.help.altair.com/2024/hwdesktop/hwx/topics/file_management/comments_hypermesh_r.htm
    HM_ASSEM("HM_ASSEM"), HM_COMP_BY_PROP("HM_COMP_BY_PROP"),
    HM_ASSOC("HM_ASSOC"), HMASSEM("HMASSEM"), HMASSEM_COMP_ID("HMASSEM_COMP_ID"), HMASSEM_ID("HMASSEM_ID"), HMASSEM_IDS("HMASSEM_IDS"),
    HMBEAMSEC("HMBEAMSEC"), HMBEGINDOC("HMBEGINDOC"),
    HMCOMP("HMCOMP"), HMCOMP_ID("HMCOMP_ID"), HMCONT("HMCONT"), HMCURVE("HMCURVE"),
    HMDB("HMDB"), HMDISPLAY("HMDISPLAY"), HMDPRP("HMDPRP"), HMENDDOC("HMENDDOC"),
    HMENT("HMENT"), HMERROR("HMERROR"),
    HMFIXEDSURFPOINT("HMFIXEDSURFPOINT"), HMFOOTERBEGIN("HMFOOTERBEGIN"), HMFOOTEREND("HMFOOTEREND"),
    HMFLAG("HMFLAG"),
    HMGPMV("HMGPMV"), HMMOVE("HMMOVE"),

    HMNAME("HMNAME"), HMNAME_ASSEM("HMNAME ASSEM"), HMNAME_COMP("HMNAME COMP"), HMNAME_GROUP("HMNAME GROUP"),
    HMNAME_MAT("HMNAME MAT"), HMNAME_PROP("HMNAME PROP"), HMNAME_SET("HMNAME SET"),

    HMOUTPUT("HMOUTPUT"), HMPLOTELM("HMPLOTELM"), HMREFSYSTEM("HMREFSYSTEM"),
    HMSET("HMSET"), HMSET_SET_ID("HMSET_SET_ID"), HMSETTYPE("HMSETTYPE"),
    HMSUPPORT("HMSUPPORT"), HMTAG("HMTAG"), HMUNSUPPORTED("HMUNSUPPORTED"),

    HWCOLOR("HWCOLOR"),

    HMNAME_BEAMSECTCOL("HMNAME BEAMSECTCOL"), HMNAME_BEAMSECT("HMNAME BEAMSECT"),
    HMNAME_BLOCK("HMNAME BLOCK"), HMNAME_CGAPG("HMNAME CGAPG"), HMNAME_CONNECTOR("HMNAME CONNECTOR"),
    HMNAME_CONTACTSURF("HMNAME CONTACTSURF"), HMNAME_CONTROLVOL("HMNAME CONTROLVOL"),
    HMNAME_CSURF("HMNAME CSURF"), HMNAME_CURVE("HMNAME CURVE"),
    HMNAME_CWELD("HMNAME CWELD"), HMNAME_DDVAL("HMNAME DDVAL"),
    HMNAME_DEQUATIONS("HMNAME DEQUATIONS"), HMNAME_DESVARS("HMNAME DESVARS"),
    HMNAME_DLINKS("HMNAME DLINKS"), HMNAME_DOBJREF("HMNAME DOBJREF"),
    HMNAME_DVPRELS("HMNAME DVPRELS"),
    HMNAME_LOADCOL("HMNAME LOADCOL"), HMNAME_LOADSTEP("HMNAME LOADSTEP"),
    HMNAME_METADATA("HMNAME METADATA"), HMNAME_OBJECTIVES("HMNAME OBJECTIVES"),
    HMNAME_OPTICONSTRAINTS("HMNAME OPTICONSTRAINTS"), HMNAME_OPTICONTROLS("HMNAME OPTICONTROLS"), HMNAME_OPTIDSCREENS("HMNAME OPTIDSCREENS"), HMNAME_OPTITABLEENTRS("HMNAME OPTITABLEENTRS"),
    HMNAME_OUTPUTBLOCKS("HMNAME OUTPUTBLOCKS"), HMNAME_PLOT("HMNAME PLOT"),
    HMNAME_SENSOR("HMNAME SENSOR"), HMNAME_SHAPE("HMNAME SHAPE"),
    HMNAME_SYSTCOL("HMNAME SYSTCOL"), HMNAME_VECTORCOL("HMNAME VECTORCOL"),


    // other
    INCLUDE("INCLUDE"),
    ENDDATA("ENDDATA");

    private final String name; // 卡片名称

    // 检查是否支持的类型
    public static boolean isSupportedCard(String cardName) {
        if (cardName == null || cardName.trim().isEmpty()) {
            return false;
        }
        return Arrays.stream(CardNameEnums.values())
            .anyMatch(type -> type.getName().equalsIgnoreCase(cardName));
    }

    public static boolean isPLoad(String cardName) {
        if (cardName == null || cardName.trim().isEmpty()) {
            return false;
        }
        if (PLOAD.getName().equals(cardName) ||
            PLOAD1.getName().equals(cardName) ||
            PLOAD2.getName().equals(cardName) ||
            PLOAD4.getName().equals(cardName) ||
            PLOADX1.getName().equals(cardName)) {
            return true;
        }
        return false;
    }

}
